#include <stdio.h>
#include "oled.h"
#include "gui.h"
#include "test.h"
//16*16/8
// #define FONT_SIZE 32 //32 = 16*16/8
// unsigned char  font_array[][FONT_SIZE]={

    
void showText(int x,int y,int font_size,char *str){
    char *tmp_str = str;
    int cur_x=x;
    int cur_y=y;
    unsigned char csize = font_size;
    while(*tmp_str != '\0')
    {
        if(tmp_str[0] > 0){
           if(font_size == 16) {
                csize = font_size/2;
            }else if(font_size == 8){
                csize = font_size/2+2;
            }
      
            GUI_ShowChar(cur_x,cur_y,tmp_str[0],font_size,1);
            tmp_str++;
        }else{
            if(font_size == 16){
                GUI_ShowFont16(cur_x,cur_y,tmp_str,1);
            }else if(font_size == 24){
                //参照showChinese自己实现
            }
            tmp_str +=3;
        
        }
        
        cur_x += csize;
        if(cur_x > WIDTH-font_size)
		{
			cur_x=0;
			cur_y+=font_size;
		}
    }
}

//const unsigned char logo[]  = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0xf0,0xff,0xff,0xff,0xff,0xdf,0xff,0xc7,0xff,0xff,0xff,0xff,0xfb,0xf0,0xff,0xff,0xfb,0xff,0xef,0xff,0xf7,0xff,0xff,0xff,0xff,0x93,0xf0,0xff,0xff,0xff,0x47,0xff,0xf9,0x6f,0xff,0xcf,0xfb,0xff,0x57,0xf0,0xff,0xff,0xfe,0x05,0xff,0xff,0x4f,0xf3,0xcf,0xfb,0xff,0x97,0xf0,0xff,0xff,0xfc,0x00,0xff,0xfb,0xbf,0xf3,0xcf,0xf8,0xff,0xe0,0xf0,0xff,0xff,0xf8,0x04,0x7f,0xfb,0xdf,0xf2,0x8f,0xe1,0xff,0x5c,0xf0,0xff,0xff,0xf1,0x6e,0x37,0xfb,0x87,0xe6,0x8f,0xe3,0xfe,0xe7,0xf0,0xff,0xff,0xf0,0x5e,0x3f,0xfb,0x1f,0xf6,0xaf,0xf7,0xfe,0xf7,0xf0,0xff,0xff,0xf0,0x38,0x37,0xfb,0x5f,0xf6,0xaf,0xe5,0xff,0xff,0xf0,0xff,0xff,0xf0,0x60,0x3f,0xf9,0xd3,0xe2,0xcf,0xec,0xff,0xe0,0xf0,0xff,0xff,0xf8,0xfe,0x3f,0xf9,0x13,0xf7,0xcf,0xce,0x7f,0x97,0xf0,0xff,0xff,0xf0,0xee,0x3f,0xfb,0x4f,0xff,0xcf,0x9f,0x3f,0xf7,0xf0,0xff,0xff,0xf8,0xc6,0x7f,0xff,0xdf,0xff,0xcf,0xff,0xff,0xc7,0xf0,0xff,0xff,0xfc,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xef,0xf0,0xff,0xff,0xbe,0x01,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0x83,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xef,0xfe,0xbb,0xab,0xbd,0xb5,0xb3,0xf5,0xf0,0xff,0xff,0xff,0xff,0xdf,0xfa,0xed,0xaf,0xdd,0xd5,0xb6,0xfd,0xf0,0xff,0xff,0xfb,0xff,0xff,0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xbf,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 };
//const unsigned char logo[] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xf6,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xdf,0x7f,0xff,0xff,0xf0,0xff,0xff,0xff,0xbf,0xdf,0xff,0xff,0xf0,0xff,0xff,0xfe,0xff,0xef,0xff,0xff,0xf0,0xff,0xff,0xfd,0xff,0x77,0xff,0xff,0xf0,0xff,0xff,0xfb,0xae,0x7d,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xde,0xff,0xff,0xf0,0xff,0xff,0xff,0x7f,0xd7,0x7f,0xff,0xf0,0xff,0xff,0xfe,0xf1,0xef,0xbf,0xff,0xf0,0xff,0xff,0xf3,0xe0,0xff,0xdf,0xff,0xf0,0xff,0xff,0xfb,0xc4,0x3f,0xef,0xff,0xf0,0xff,0xff,0xdf,0x06,0x1e,0xf7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,0xf0,0xb7,0x0f,0xff,0xff,0xff,0xff,0x0d,0xd0,0xf3,0x1f,0xff,0xff,0xff,0xff,0x0f,0xd0,0xf3,0x1c,0x63,0x31,0x8c,0xc7,0x8f,0xd0,0xf7,0x00,0x00,0x00,0x00,0x00,0x0d,0xd0,0xf7,0x80,0x01,0xff,0xe0,0x00,0x1f,0xf0,0xff,0xc0,0x7f,0xff,0xff,0xc0,0x3e,0xf0,0xf7,0xff,0xff,0xff,0xff,0xfc,0xfd,0xf0,0xff,0xff,0xde,0x77,0xbf,0xef,0xff,0xf0,0xff,0xff,0xdf,0xe3,0xbd,0xcf,0xff,0xf0,0xff,0xff,0x1e,0x66,0x3b,0xcf,0xff,0xd0,0xdf,0xff,0xfe,0xe7,0x7b,0xff,0xff,0x70,0xf7,0xff,0xdf,0xff,0x7d,0xdf,0xfc,0xf0,0xfc,0xff,0xff,0xff,0xff,0xff,0xf7,0xf0,0xff,0xbf,0xff,0xff,0xff,0xff,0x9f,0xf0,0xff,0xf7,0xff,0xfd,0x7f,0xfc,0xff,0xf0,0xff,0xfe,0x7f,0xfe,0xff,0xe7,0xff,0xf0,0xff,0xff,0xf1,0xff,0xf8,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 };
// width: 60, height: 59
const unsigned char log[] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xf6,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xdf,0x7f,0xff,0xff,0xf0,0xff,0xff,0xff,0xbf,0xdf,0xff,0xff,0xf0,0xff,0xff,0xfe,0xff,0xef,0xff,0xff,0xf0,0xff,0xff,0xfd,0xff,0x77,0xff,0xff,0xf0,0xff,0xff,0xfb,0xae,0x7d,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xde,0xff,0xff,0xf0,0xff,0xff,0xff,0x7f,0xd7,0x7f,0xff,0xf0,0xff,0xff,0xfe,0xf1,0xef,0xbf,0xff,0xf0,0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83,0x8c,0x7f,0x18,0xfc,0x19,0xb0,0xff,0x83,0x9c,0xe7,0x39,0xd8,0x1f,0xf0,0xbb,0x03,0x39,0xce,0x73,0x9c,0x1b,0xf0,0xb7,0x0f,0xff,0xff,0xff,0xff,0x0d,0xd0,0xf3,0x1f,0xff,0xff,0xff,0xff,0x0f,0xd0,0xf3,0x1c,0x63,0x31,0x8c,0xc7,0x8f,0xd0,0xf7,0x00,0x00,0x00,0x00,0x00,0x0d,0xd0,0xf7,0x80,0x01,0xff,0xe0,0x00,0x1f,0xf0,0xff,0xc0,0x7f,0xff,0xff,0xc0,0x3e,0xf0,0xf7,0xff,0xff,0xff,0xff,0xfc,0xfd,0xf0,0xff,0xff,0xde,0x77,0xbf,0xef,0xff,0xf0,0xff,0xff,0xdf,0xe3,0xbd,0xcf,0xff,0xf0,0xff,0xff,0x1e,0x66,0x3b,0xcf,0xff,0xd0,0xdf,0xff,0xfe,0xe7,0x7b,0xff,0xff,0x70,0xf7,0xff,0xdf,0xff,0x7d,0xdf,0xfc,0xf0,0xfc,0xff,0xff,0xff,0xff,0xff,0xf7,0xf0,0xff,0xbf,0xff,0xff,0xff,0xff,0x9f,0xf0,0xff,0xf7,0xff,0xfd,0x7f,0xfc,0xff,0xf0,0xff,0xfe,0x7f,0xfe,0xff,0xe7,0xff,0xf0,0xff,0xff,0xf1,0xff,0xf8,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0 };
void test_led_screen(void)
{	
    char data[100]={0};
    printf("before oled clear \r\n");
    OLED_Init();			   //初始化OLED  
    


     OLED_Clear(0);   
     //GUI_DrawCircle(10, 10, 1, 8);
     GUI_DrawBMP(30,0,60,59, log, 1); 
    // // GUI_DrawTriangel(30,10,100,40,50,79,1);
    //GUI_ShowChinese(0,0,16,"风扇",1);
    // GUI_ShowChinese(0,0,16,"在此输风扇打开23232",1);
    // showText("在@此!输风扇打开23232");
     OLED_Display();
      sleep(5);
    // while(1){    
         int x = 0;
         int y = 0;

         while(1){
             OLED_Clear(0);    
             sprintf(data,"Tem:%d,humi=%d",x,y);
             GUI_ShowString(x++,y++,data, 16 ,1  );
             OLED_Display();
             usleep(500000);

             if(y >20)
             {
                // break;
                x = 0;
                y = 0;
             }
         }

         

    // }
   
}

